package com.sooth.micro.camunda.service;

import com.dream.system.config.Page;
import com.sooth.micro.camunda.view.ProcessDefinitionDto;
import org.camunda.bpm.engine.history.HistoricActivityInstance;
import org.camunda.bpm.engine.history.HistoricProcessInstance;
import org.camunda.bpm.engine.history.HistoricTaskInstance;
import org.camunda.bpm.engine.repository.Deployment;
import org.camunda.bpm.engine.repository.ProcessDefinition;
import org.camunda.bpm.engine.task.Task;
import org.camunda.bpm.model.bpmn.BpmnModelInstance;
import org.camunda.bpm.model.bpmn.instance.FlowElement;

import java.util.Date;
import java.util.List;
import java.util.Map;

public interface ICamundaApiService {
    String CAMUNDA_BPM_DATASOURCE = "camundaBpmDataSource";
    String CAMUNDA_BPM_ENABLED = "camunda.bpm.enabled";

    /**
     * 流程部署
     *
     * @param processId
     * @param processName
     * @param processJson
     * @param versionTag
     * @return
     */
    Deployment deploy(String processId, String processName, String processJson, String versionTag);

    Page<ProcessDefinition> processDefinitionList(ProcessDefinitionDto processDefinitionDto, Page page);

    List<ProcessDefinition> processDefinitionListByKey(String processDefinitionKey);

    /**
     * 挂起流程
     *
     * @param processDefinitionId
     */
    void suspendProcessDefinitionById(String processDefinitionId);

    /**
     * 激活流程
     *
     * @param processDefinitionId
     */
    void activateProcessDefinitionById(String processDefinitionId);

    /**
     * 流程启动
     */
    void start(String processDefinitionId, Map<String, Object> formData);

    /**
     * 提交
     */
    void approve(String taskId, Map<String, Object> formData, String userId);

    /**
     * 拒绝
     *
     * @param taskId
     */
    void reject(String taskId);

    /**
     * 委派
     */
    void delegate(String taskId, String userId);

    /**
     * 委派人完成
     */
    void resolveTask(String taskId, Map<String, Object> formData);

    /**
     * 撤销
     */
    void revoke(String taskId);

    /**
     * 转办
     */
    void transfer(String taskId, String userId);

    /**
     * 查看个人待办
     */
    Page<Task> todoList(List<String> candidateList, String taskName, Date startDate, Date endDate, Page page);

    /**
     * 查看个人已办
     */
    Page<HistoricTaskInstance> todoneList(String userId, String taskName, Date startDate, Date endDate, Page page);

    /**
     * 查看个人发起
     */
    Page<HistoricProcessInstance> applyList(String userId, String processName, Date startDate, Date endDate, Page page);

    BpmnModelInstance bpmnModelInstance(String processDefinitionId);

    ProcessDefinition processDefinition(String processDefinitionId);

    HistoricProcessInstance historicProcessInstance(String processInstanceId);

    Task task(String taskId);

    FlowElement flowElement(String processDefinitionId, String nodeKey);

    Map<String, Object> formData(String processInstanceId);

    Object getVariable(String processInstanceId, String variableName);

    void deleteDeployment(String deploymentId);

    Deployment deployment(String deploymentId);

    List<HistoricActivityInstance> historicActivityInstanceList(String processInstanceId);
}
